class Solution {
public:
    int findNumberOfLIS(vector<int>& nums) {
        int n = nums.size();
        int ret = 1;
        vector<vector<int>> dp(n, vector<int>(2, 1));

        for (int i = 1; i < n; ++i)
        { 
            int max = 1;
            for (int j = i - 1; j >= 0; --j)
            {
                if (nums[i] > nums[j])
                {
                    if (dp[i][0] == 1 + dp[j][0])
                        max += dp[j][1];
                    else if (dp[i][0] < 1 + dp[j][0])
                    {
                        dp[i][0] = 1 + dp[j][0];
                        max = dp[j][1];
                    }
                    else
                        continue;
                }
            }
            dp[i][1] = max;
        }

        int max = dp[0][0];
        for (int i = 1; i < n; ++i)
        {
            if (dp[i][0] == max)
                ret += dp[i][1];
            else if (dp[i][0] > max)
            {
                max = dp[i][0];
                ret = dp[i][1];
            }
            else
                continue;
        }

        return ret;
    }
};